package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TRYSTUDENTMapper;
import com.ruoyi.system.domain.TRYSTUDENT;
import com.ruoyi.system.service.ITRYSTUDENTService;
import com.ruoyi.common.core.text.Convert;

/**
 * 试听生管理Service业务层处理
 *
 * @author ruoyi
 * @date 2021-11-08
 */
@Service
public class TRYSTUDENTServiceImpl implements ITRYSTUDENTService
{
    @Autowired
    private TRYSTUDENTMapper tRYSTUDENTMapper;

    /**
     * 查询试听生管理
     *
     * @param tryId 试听生管理主键
     * @return 试听生管理
     */
    @Override
    public TRYSTUDENT selectTRYSTUDENTByTryId(String tryId)
    {
        return tRYSTUDENTMapper.selectTRYSTUDENTByTryId(tryId);
    }

    /**
     * 查询试听生管理列表
     *
     * @param tRYSTUDENT 试听生管理
     * @return 试听生管理
     */
    @Override
    public List<TRYSTUDENT> selectTRYSTUDENTList(TRYSTUDENT tRYSTUDENT)
    {
        return tRYSTUDENTMapper.selectTRYSTUDENTList(tRYSTUDENT);
    }

    /**
     * 新增试听生管理
     *
     * @param tRYSTUDENT 试听生管理
     * @return 结果
     */
    @Override
    public int insertTRYSTUDENT(TRYSTUDENT tRYSTUDENT)
    {
        if(tRYSTUDENT.getTryId()==null||"".equals(tRYSTUDENT.getTryId())){
            String s1 = DateUtils.dateTime();
            String uuid = UUID.randomUUID().toString();
            String s="staff"+s1+uuid.substring(uuid.length()-5,uuid.length()-1);
            tRYSTUDENT.setTryId(s);
        }
        return tRYSTUDENTMapper.insertTRYSTUDENT(tRYSTUDENT);
    }

    /**
     * 修改试听生管理
     *
     * @param tRYSTUDENT 试听生管理
     * @return 结果
     */
    @Override
    public int updateTRYSTUDENT(TRYSTUDENT tRYSTUDENT)
    {

        return tRYSTUDENTMapper.updateTRYSTUDENT(tRYSTUDENT);
    }

    /**
     * 批量删除试听生管理
     *
     * @param tryIds 需要删除的试听生管理主键
     * @return 结果
     */
    @Override
    public int deleteTRYSTUDENTByTryIds(String tryIds)
    {
        return tRYSTUDENTMapper.deleteTRYSTUDENTByTryIds(Convert.toStrArray(tryIds));
    }

    /**
     * 删除试听生管理信息
     *
     * @param tryId 试听生管理主键
     * @return 结果
     */
    @Override
    public int deleteTRYSTUDENTByTryId(String tryId)
    {
        return tRYSTUDENTMapper.deleteTRYSTUDENTByTryId(tryId);
    }
}
